<?php
include"assets/config/config.php";

if (!empty($_FILES["picture"]["tmp_name"])){
	$jenis_gambar = $_FILES['picture']['type'];
	//echo $jenis_gambar;
	$namafolder="assets/picture/";
	$item_name=$_POST['item_name'];
	$cattegory = $_POST['cattegory'];
	$mark = $_POST['mark'];
	$type_buy = $_POST['type_buy'];
	$point_unit = $_POST['point_unit'];
	$point_price = $_POST['point_price'];
	$one_day = $_POST['one_day'];
	$three_day = $_POST['three_day'];
	$seven_day = $_POST['seven_day'];
	$thirty_day = $_POST['thirty_day'];
	$damage = $_POST['damage'];
	$fire_speed = $_POST['fire_speed'];
	$accuracy = $_POST['accuracy'];
	$ammo_1 = $_POST['ammo_1'];
	$ammo_2 = $_POST['ammo_2'];
	$v_recoil = $_POST['v_recoil'];
	$h_recoil = $_POST['h_recoil'];
	$move_speed = $_POST['move_speed'];
	$range = $_POST['range'];
	$status = $_POST['status'];
	//echo "$duration<br />";
	//echo $item_name;
	if($jenis_gambar=="image/jpeg" || $jenis_gambar=="image/jpg" || $jenis_gambar=="image/gif" || $jenis_gambar=="image/png"){
		//echo"a";
		$gambar = $namafolder . basename($_FILES['picture']['name']);
		$judul_gambarnya = $_FILES['picture']['name'];
		if (move_uploaded_file($_FILES['picture']['tmp_name'], $gambar)){
			//echo"b";
			$sql="insert into tbl_weapon(id_item, picture, item_name, cattegory, mark, type_buy, point_unit, point_price, one_day, three_day, seven_day, thirty_day, damage, fire_speed, akurasi, ammo, v_recoil, h_recoil, move_speed, range1, status)values('', '$judul_gambarnya', '$item_name', '$cattegory', '$mark', '$type_buy', '$point_unit', '$point_price', '$one_day', '$three_day', '$seven_day', '$thirty_day', '$damage', 'fire_speed', '$accuracy', '$ammo', '$v_recoil', '$h_recoil', '$move_speed', '$range', '$status')";
			$res=mysql_query($sql) or die (mysql_error());
			
			header("location:index.php");
		}else{
			echo "Gambar gagal dikirim";
		}
	}else{
		echo "Jenis gambar yang anda kirim salah. Harus .jpg .gif .png";
}
		}else{
			echo "Anda belum memilih gambar";
		}
?>